import Util from './Util'

const list = [
    {
        level: 1,
        type: '基础组件',
        render: 'text',
        label: '单行文本',
        icon: 'iconfont icon-input',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '占位', prop: 'placeholder',type: 'input', value: ''},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
            { label: '自动焦点', prop: 'autofocus',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
            { value: 'focus', label: '获得焦点' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'textarea',
        label: '多行文本',
        icon: 'iconfont icon-input',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '占位', prop: 'placeholder',type: 'input', value: ''},
            { label: '行数', prop: 'rows',type: 'number', value: 1 },
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
            { label: '自动焦点', prop: 'autofocus',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'password',
        label: '密码',
        icon: 'iconfont icon-mima',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '占位', prop: 'placeholder',type: 'input', value: ''},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
            { label: '自动焦点', prop: 'autofocus',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    }, {
        level: 1,
        type: '基础组件',
        render: 'number',
        label: '数字',
        icon: 'iconfont icon-num-list',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '占位', prop: 'placeholder',type: 'input', value: ''},
            { label: '最大值', prop: 'max',type: 'number' },
            { label: '最小值', prop: 'min',type: 'number' },
            { label: '步长', prop: 'step',type: 'number', value: 1},
            { label: '精度', prop: 'precision',type: 'number', value: 0 },
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select',lifeScopes: ['table'],
                options: [{value:' ',label: '禁用'},{value:'>',label: '大于'},{value:'=',label: '等于'},{value:'<',label: '小于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'date',
        label: '日期',
        icon: 'iconfont icon-riqi1',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'between',label: '在范围内'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'daterange',
        label: '日期范围',
        icon: 'iconfont icon-riqifanwei1',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'between',label: '在范围内'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'datetime',
        label: '日期时间',
        icon: 'iconfont icon-a-ziyuan22',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'between',label: '在范围内'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'datetimerange',
        label: '时间范围',
        icon: 'iconfont icon-a-ziyuan22',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'between',label: '在范围内'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'select',
        label: '下拉选项',
        icon: 'iconfont icon-xialaxuanze',
        attributes: [
            { label: '占位', prop: 'placeholder',type: 'input', value: ''},
            { label: '选择数量', prop: 'multipleLimit',type: 'number', value: -1},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '清空', prop: 'clearable',type: 'switch', value: true},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
            { value: 'requestBefore', label: '数据源加载前' },
            { value: 'requestAfter', label: '数据源加载后' },
        ],
        apis: [
            { value: 'source', label: '数据源' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'radio',
        label: '单选按钮',
        icon: 'iconfont icon-a-ziyuan9',
        attributes: [
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
            { value: 'requestBefore', label: '数据源加载前' },
            { value: 'requestAfter', label: '数据源加载后' },
        ],
        apis: [
            { value: 'source', label: '数据源' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'checkbox',
        label: '多选按钮',
        icon: 'iconfont icon-duoxuananniu',
        attributes: [
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'}]},
            { label: '清空', prop: 'clearable',type: 'switch', value: true},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
            { value: 'requestBefore', label: '数据源加载前' },
            { value: 'requestAfter', label: '数据源加载后' },
        ],
        apis: [
            { value: 'source', label: '数据源' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'switch',
        label: '开关',
        icon: 'iconfont icon-switch-info',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '打开描述', prop: 'activeText',type: 'input', value: ''},
            { label: '关闭描述', prop: 'inactiveText',type: 'input', value: ''},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'<>',label: '不等于'},{value:'=',label: '等于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'rate',
        label: '评分',
        icon: 'iconfont icon-pingfen1',
        attributes: [
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '半选', prop: 'allowHalf',type: 'switch', value: true},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'color',
        label: '颜色',
        icon: 'iconfont icon-colorSelector',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'change', label: '值改变' },
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'progress',
        label: '进度条',
        icon: 'iconfont icon-yiqiyibiao',
        attributes: [
            { label: '类型', prop: 'type',type: 'select', value: 'line', options: [{value:'line',label: '线型'},{value:'circle',label: '圆形'}]},
            { label: '宽度', prop: 'strokeWidth',type: 'number', value: 18},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],
                options: [{value:' ',label: '禁用'},{value:'>',label: '大于'},{value:'=',label: '等于'},{value:'<',label: '小于'}]},
        ],
        actions: [
            { value: 'created', label: '创建' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'icon',
        label: '图标',
        icon: 'iconfont icon-flat',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
            { label: '清空', prop: 'clearable',type: 'switch', value: true},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'},{value:'=',label: '等于'}]},
        ],
        actions: [
            { value: 'created', label: '创建' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'code',
        label: '代码',
        icon: 'iconfont icon-daimashili',
        attributes: [
            { label: '语法', prop: 'language',type: 'select', value: 'json', options: [{value:'json',label: 'JSON'},{value:'javascript',label: 'JS'},{value:'java',label: 'JAVA'},{value:'mysql',label: 'SQL'}]},
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
            { label: '表格过滤', prop: 'tableFilter',type: 'select', lifeScopes: ['table'],options: [{value:' ',label: '禁用'},{value:'like',label: '包含'}]},
        ],
        actions: [
            { value: 'created', label: '创建' }
        ]
    },{
        level: 1,
        type: '基础组件',
        render: 'button',
        label: '按钮',
        icon: 'iconfont icon-anniu',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '类型', prop: 'type',type: 'select',value: 'primary', options: [{value:'primary',label: '主要'},{value:'success',label: '成功'},{value:'warning',label: '警告'},{value:'danger',label: '危险'},{value:'info',label: '信息'},{value:'text',label: '文本'}]},
            { label: '圆角', prop: 'round',type: 'switch', value: false},
            { label: '圆形', prop: 'circle',type: 'switch', value: false},
            { label: '图标', prop: 'icon',type: 'icon', value: '' },
            { label: '禁用', prop: 'disabled',type: 'switch', value: false},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'click', label: '点击' },
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'buttonGroup',
        label: '按钮组',
        icon: 'iconfont icon-anniuzu',
        attributes: [
            { label: '展示数量', prop: 'showCount',type: 'number', value: 3 },
            { label: '对齐方式', prop: 'align',type: 'select', value: 'flex-start', options: [{value:'flex-start',label: '靠左'},{value:'center',label: '居中'},{value:'flex-end',label: '靠右'}] },
            { label: '表格列宽', prop: 'tableWidth',type: 'input',lifeScopes: ['table'] },
        ],
        actions: [
            { value: 'created', label: '创建' }
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'file',
        label: '文件资源',
        icon: 'iconfont icon-wenjianjia',
        attributes: [
            { label: '最大数量', prop: 'limit',type: 'number', value: 1 },
            { label: '数据指令', prop: 'callDb',type: 'input', value: '' },
            { label: '文件指令', prop: 'callStore',type: 'input', value: '' },
            { label: '实体属性', prop: 'entityValue',type: 'input', value: '' },
            { label: '实体类型', prop: 'entityType',type: 'input', value: '' },
            { label: '资源分类', prop: 'resourceType',type: 'input', value: '' },
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'onSuccess', label: '上传成功' },
            { value: 'onRemove', label: '删除' },
        ],
        apis: [
            { value: 'source', label: '资源加载' },
        ]
    }, {
        level: 2,
        type: '高级组件',
        render: 'form',
        label: '表单',
        icon: 'iconfont icon-form-task',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', value: 'mini', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '标签位置', prop: 'labelPosition',type: 'select', value: 'right', options: [{value:'left',label: '靠左'},{value:'right',label: '靠右'},{value:'top',label: '顶部'}]},
            { label: '标签宽度', prop: 'labelWidth',type: 'input', value: '80px'},
            { label: '标签后缀', prop: 'labelSuffix',type: 'input', value: ''},
            { label: '主键属性', prop: 'rowKey',type: 'input'},
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'requestBefore', label: '数据源加载前' },
            { value: 'requestAfter', label: '数据源加载后' },
        ],
        apis: [
            { value: 'source', label: '数据源' }
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'table',
        label: '表格',
        icon: 'iconfont icon-table',
        attributes: [
            { label: '大小', prop: 'size',type: 'select', options: [{value:'medium',label: '大'},{value:'small',label: '中'},{value:'mini',label: '小'}]},
            { label: '主键属性', prop: 'rowKey',type: 'input'},
            { label: '高度', prop: 'height',type: 'input' },
            { label: '最大高度', prop: 'maxHeight',type: 'input'},
            { label: '展示表头', prop: 'showHeader',type: 'switch', value: true },
            { label: '展示序号', prop: 'showIndex',type: 'switch', value: true },
            { label: '支持展开', prop: 'showExpand',type: 'switch', value: false },
            { label: '选择框', prop: 'selectBox',type: 'switch', value: true },
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'select', label: '数据选择' },
            { value: 'rowClick', label: '数据选择' },
            { value: 'requestBefore', label: '数据源加载前' },
            { value: 'requestAfter', label: '数据源加载后' },
        ],
        apis: [
            { value: 'source', label: '数据源' },
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'divider',
        label: '分割线',
        icon: 'iconfont icon-feng',
        attributes: [
            { label: '文案位置', prop: 'contentPosition',type: 'select', value: 'center', options: [{value:'center',label: '居中'},{value:'left',label: '靠左'},{value:'right',label: '靠右'}]},
        ],
        actions: [
            { value: 'created', label: '创建' },
        ]
    }/*,{
        level: 2,
        type: '高级组件',
        render: 'formTable',
        label: '管理表格',
        icon: 'iconfont icon-form-setting',
        attributes: [
            { label: '设计模式', prop: 'showType',type: 'select', value: 'table', options: [{value:'table',label: '表格'},{value:'form',label: '表单'}, {value:'formTable',label: '行内表单'} ]},
            { label: '表格属性', prop: 'tableMapper',type: 'input' },
            { label: '应用指令', prop: 'appCmd',type: 'input' },
            { label: '调用指令', prop: 'callCmd',type: 'input' },
            { label: '应用版本', prop: 'versionId',type: 'input' }
        ],
        actions: [
            { value: 'created', label: '创建' },
            { value: 'requestBefore', label: '数据源加载前' },
            { value: 'requestAfter', label: '数据源加载后' },
        ],
        apis: [
            { value: 'save', label: '表单保存' },
            { value: 'remove', label: '行内删除' }
        ]
    }*/,{
        level: 2,
        type: '高级组件',
        render: 'view',
        label: '视图模型',
        icon: 'iconfont icon-form-setting',
        attributes: [
            { label: '视图指令', prop: 'callCmd',type: 'input' }
        ],
        actions: []
    },{
        level: 2,
        type: '高级组件',
        render: 'tab',
        label: '标签',
        icon: 'iconfont icon-table-four',
        attributes: [
            { label: '水平排列', prop: 'justify',type: 'select', value: 'start',options: [{value:'start',label: '靠左'},{value:'end',label: '靠右'},{value:'center',label: '居中'},{value:'space-around',label: '两侧间隔相等'},{value:'space-between',label: '两侧对齐'}]},
            { label: '垂直排列', prop: 'align',type: 'select', value: 'middle', options: [{value:'top',label: '靠上'},{value:'middle',label: '居中'},{value:'bottom',label: '靠下'}]},
            { label: '间隔', prop: 'gutter',type: 'number', value: 0}
        ],
        actions: [
            { value: 'created', label: '创建' }, { value: 'tabClick', label: '标签点击' },
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'report',
        label: '报告组件',
        icon: 'el-icon-document',
        attributes: [
            { label: '数据指令', prop: 'callDb',type: 'input', value: '' },
            { label: '文件指令', prop: 'callStore',type: 'input', value: '' },
            { label: '模板标签', prop: 'templateLabel',type: 'input', value: '' },
            { label: '签名标签', prop: 'signLabel',type: 'input', value: '' },
            { label: '实体类型', prop: 'entityType',type: 'input', value: '' },
            { label: '实体属性', prop: 'entityValue',type: 'input', value: '' },
            { label: '过滤条件', prop: 'filterOp',type: 'select', value: '=',
                options: [
                    {value:'=',label: '等于'},
                    {value:'like',label: '包含'},
                    {value:'in',label: '列表'}
                ]
            }
        ],
        actions: [
            { value: 'created', label: '创建' }
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'div',
        label: '行级布局',
        icon: 'iconfont icon-ico2',
        attributes: [
            { label: '高度', prop: 'height',type: 'input', value: '100%' },
            { label: '宽度', prop: 'width',type: 'input', value: '100%' },
            { label: '布局方式', prop: 'flexFlow',type: 'select', value: 'row nowrap',options: [{value:'row nowrap',label: '横向不换行'},{value:'row wrap',label: '横向换行'},{value:'column nowrap',label: '纵向不换行'},{value:'column wrap',label: '纵向换行'}]},
            { label: '主轴方式', prop: 'justifyContent',type: 'select', value: 'flex-start',options: [{value:'flex-start',label: '左对齐'},{value:'flex-end',label: '右对齐'},{value:'center',label: '居中'},{value:'space-around',label: '两侧对齐'},{value:'space-between',label: '两端对齐'}]},
            { label: '交叉轴', prop: 'alignItems',type: 'select', value: 'stretch', options: [{value:'flex-start',label: '起点对齐'},{value:'flex-end',label: '终点对齐'},{value:'center',label: '中点对齐'},
                    {value:'baseline',label: '基线对齐'},{value:'stretch',label: '填充'}]},
        ],
        actions: [
            { value: 'created', label: '创建' }, { value: 'tabClick', label: '标签点击' },
        ]
    },{
        level: 2,
        type: '高级组件',
        render: 'window',
        label: '弹窗',
        icon: 'iconfont icon-chuangkou1',
        attributes: [
            { label: '标题', prop: 'title',type: 'input', value: '窗口' },
            { label: '宽度', prop: 'width',type: 'input', value: '90%' },
            { label: '全屏', prop: 'fullscreen',type: 'switch', value: false },
            { label: '视图指令', prop: 'callCmd',type: 'input' },
        ],
        actions: [
            { value: 'created', label: '创建' },
        ]
    },/*{
        level: 2,
        type: '高级组件',
        render: 'model',
        label: '数据模型',
        icon: 'iconfont icon-chuangkou1',
        attributes: [
            { label: '渲染模式', prop: 'modelType',type: 'select', value: 'manager',options: [{value:'manager',label: '管理'},{value:'form',label: '表单'},{value:'table',label: '表格'}]},
            { label: '调用指令', prop: 'callCmd',type: 'input' },
        ],
        actions: [
            { value: 'created', label: '创建' },
        ]
    },*/{
        level: 2,
        type: '辅助组件',
        render: 'tabPane',
        label: '标签页',
        hidden: true,
        icon: 'iconfont icon-table-four',
        attributes: [],
        actions: []
    }
]

const renderDefine = {
    list: function () {
        return Util.copy(list)
    },
    map: function () {
        const map = {}
        list.forEach(item => {
            map[item.render] = Util.copy(item)
        })
        return map
    },
    find: function (render) {
        const item = list.find(item => item.render === render)
        return Util.copy(item)
    },
    /**
     * 组件属性验证
     * 验证属性是否应用于组件
     * 应用条件有：
     * 1. 组件可见范围未设置或者设置未all时
     * 2. 属性的可见范围包含组件的可见范围
     * @param attr        属性
     * @param element     组件
     * @returns {boolean} 是否适用
     */
    renderAttrCheck: function(attr, element) {
        if (Util.isEmpty(attr) || Util.isEmpty(element)){
            return false
        }
        if (Util.isEmpty(element.lifeScope) || element.lifeScope === 'all') {
            return true
        }
        const lifeScopes = attr.lifeScopes || []
        if (Util.isEmpty(lifeScopes) || lifeScopes.includes(element.lifeScope)) {
            return true
        }
        return false
    },
    /**
     * 获取组件属性
     * 过滤当前组件定义属性，属性需要在当前组件展示范围(lifeScope)呢可见的属性
     * @param element   当前组件
     * @returns {*[]}   组件下属性
     */
    findAttrs: function (element) {
        const { render } = element
        if (!render) {
            return []
        }
        const renderItem = this.find(render)
        if (!renderItem) {
            return  []
        }
        const attributes = renderItem.attributes || []
        return attributes.filter(item => this.renderAttrCheck(item,element))
    },
    /**
     * 获取组件自身的属性和父级组件可见属性
     * @param element
     * @returns {*[]}
     */
    findAllAttrs: function (element) {
        // 获取自身组件属性
        /*if (element.prentRender) {
            // 获取父级组件属性
            const parentAttr = this.findAttrs(element.prentRender)
            parentAttr.forEach(item => {
                selfAttr.push(item)
            })
        }*/
        return this.findAttrs(element)
    },
    /**
     * 创建组件
     * @param render    类型
     * @param label     名称
     * @param prentRender   父级类型
     * @param mapper        属性
     * @returns {{visible: boolean, elements: *[], prentRender, mapper: string, style: {}, label, render, key: string, events: *[], props: {}}}
     */
    create: function (render, label, prentRender, mapper) {
        const element = {
            render: render, prentRender, label, mapper: mapper || Util.uuid(6), key: Util.uuid()
        }
        this.autoFill(element)
        return element
    },
    createBtn(label, prentRender, mapper, events,props) {
        const btn = this.create('button',label,prentRender,mapper)
        if (!Util.isEmpty(events)) {
            events.forEach(item => {
                btn.events.push(item)
            })
        }
        if (!Util.isEmpty(props)) {
            Util.copyAttr(props, btn.props, null)
        }
        return btn
    },
    setValue($this, element, prop, value) {
        if ($this) {
            $this.$set(element, prop, value)
        } else {
            Reflect.set(element, prop, value)
        }
    },
    /**
     * 组件属性补充
     * @param element
     * @param $this  组件
     */
    autoFill: function (element, $this) {
        const keys = Object.keys(element)
        // 渲染唯一值
        if (!keys.includes('key')) {
            this.setValue($this,element, 'key', Util.uuid())
        }
        // 组件属性
        if (!keys.includes('mapper')) {
            this.setValue($this,element, 'mapper', Util.uuid(6))
        }
        // 组件级别
        if (!keys.includes('level')) {
            this.setValue($this,element, 'level', 1)
        }
        // 组件名称
        if (!keys.includes('label')) {
            this.setValue($this,element, 'label', '')
        }
        // 组件是否渲染
        if (!keys.includes('visible')) {
            this.setValue($this,element, 'visible', true)
        }
        // 组件自身属性配置
        if (!keys.includes('props')) {
            this.setValue($this,element, 'props', { })
        }
        // 组件样式
        if (!keys.includes('style')) {
            this.setValue($this,element, 'style', { })
        }
        // 组件事件 [{trigger:'触发点', eventScript: '事件函数'}]
        if (!keys.includes('events')) {
            this.setValue($this,element, 'events', [])
        }
        // 组件请求 [ { trigger:'目标请求', config: { 请求配置 } }], 由组件定义中的api来
        if (!keys.includes('requests')) {
            this.setValue($this,element, 'requests', [])
        }
        if (!keys.includes('options')) {
            this.setValue($this,element, 'options', [])
        }
        // 组件级别
        if (!Util.isEmpty(element.render)) {
            const renderItem = this.find(element.render)
            if (renderItem) {
                this.setValue($this,element, 'level', renderItem.level)
            }
        }

        const { props, level, render } = element
        if (level === 1) {
            // 组件是否需要值
            if (!keys.includes('needValue')) {
                this.setValue($this,element, 'needValue', false)
            }
            if ('textarea' === render) {
                if (!keys.includes('sm')) {
                    this.setValue($this,element, 'sm', 24)
                }
                if (!keys.includes('lg')) {
                    this.setValue($this,element, 'lg', 24)
                }
            }
        }
        // 组件标签宽度
        if (!keys.includes('labelWidth')) {
            this.setValue($this,element, 'labelWidth', level > 1 ? '0' : '')
        }
        // 响应式 xs:<768px, sm:≥768px, lg:≥1200px
        if (!keys.includes('xs')) {
            this.setValue($this,element, 'xs', 24)
        }
        if (!keys.includes('sm')) {
            this.setValue($this,element, 'sm', level > 1 ? 24: 12)
        }
        if (!keys.includes('lg')) {
            this.setValue($this,element, 'lg', level > 1 ? 24: 6)
        }
        // 下级组件
        if (!keys.includes('elements')) {
            this.setValue($this,element, 'elements', [])
        }
        // 展示范围，值为父级组件render属性，可以指定某个组件在表格或者表单内可见
        if (!keys.includes('lifeScope')) {
            this.setValue($this,element, 'lifeScope', 'all')
        }
        // 组件自身属性赋默认值
        const attrs = this.findAllAttrs(element)
        if (attrs) {
            attrs.forEach(attr => {
                if (!Object.keys(props).includes(attr.prop)) {
                    this.setValue($this,props, attr.prop, attr.value)
                }
            })
            console.debug('组件属性:', element.mapper, props)
        }
    }
}
export default renderDefine
